package com.aconcagua.samples.charts.service.mock {
  import com.aconcagua.samples.charts.state.model.Series;
  import com.aconcagua.samples.charts.state.model.SeriesElement;
  
  import mx.collections.ArrayCollection;
  
  public class MockChartService {
    public function getData(dateFrom: Date, dateTo: Date): ArrayCollection {
      var data: ArrayCollection = new ArrayCollection();
      data.addItem(new Series(this.createRandomData(dateFrom, dateTo)));
     
      return data;
    }
    
    private function createRandomData(dateFrom: Date, dateTo: Date): ArrayCollection {
      var step: int = 1000 * 60 * 60 * 30;

      var data: ArrayCollection = new ArrayCollection();
      for (var time: Number = dateFrom.time; time < dateTo.time; time += step) {
        data.addItem(new SeriesElement(new Date(time),  Math.random() * 1000));
      }
      
      return data;
    }
  }
}